package treatBehavior
{
	import flash.geom.Point;
	
	public class BezierBehavior implements ITreatBehavior
	{
//-----------------------------------------------------------------------------------------------PUBLIC---------------------------------
													//================ Properties ===============
													
													//================ Public Methods ===========
		public function BezierBehavior(aVal:Array):void{
			arr=aVal;
			initVar();
		}
		public function getTreatArr():Array{
			resultArr.push(arr[0]);
			for(var i:uint=0;i<arr.length-2;i++){
				var firstP:Point=new Point();
				var secP:Point=new Point();
				firstP.x=(arr[i].x+arr[i+1].x)/2;
				firstP.y=(arr[i].y+arr[i+1].y)/2;
				secP.x=(arr[i+1].x+arr[i+2].x)/2;
				secP.y=(arr[i+1].y+arr[i+2].y)/2;
				for(var t:uint=0;t<100;t++){
					var s:Number=t*.01;
					var tempX:Number=Math.pow(1-s,2)*firstP.x+2*s*(1-s)*arr[i+1].x+Math.pow(s,2)*secP.x;
					var tempY:Number=Math.pow(1-s,2)*firstP.y+2*s*(1-s)*arr[i+1].y+Math.pow(s,2)*secP.y;
					var tempP:Point=new Point(tempX,tempY);
					resultArr.push(tempP);
				}
			}
			resultArr.push(arr[arr.length-1]);
			return resultArr;
		}
//-----------------------------------------------------------------------------------------------PRIVATE--------------------------------													
													//================ Properties ===============
		private var arr:Array;
		private var resultArr:Array;
													//================ Private Methods ==========
		private function initVar():void{
			resultArr=new Array();
		}
	}
}